const { defineConfig } = require("@vue/cli-service");
const { name } = require("./package");
const path = require("path");

const port = 6001;

module.exports = defineConfig({
    transpileDependencies: true,
    devServer: {
        port: port,
        headers: {
            "Access-Control-Allow-Origin": "*",
        },
        static: {
            directory: path.join(__dirname, "dist"),
            publicPath: "/dist/"  // 修改静态资源服务路径
        }
    },
    publicPath: process.env.NODE_ENV === "production" 
        ? `//localhost:${port}/dist/`  // 添加dist目录
        : `//localhost:${port}/`,
    configureWebpack: {
        output: {
            publicPath: process.env.NODE_ENV === "production" 
                ? `//localhost:${port}/dist/`  // 同步添加dist
                : `//localhost:${port}/`,
            library: `${name}-[name]`,
            libraryTarget: "umd",
            chunkLoadingGlobal: `webpackJsonp_${name}`,
        },
    },
});
